package com.ccxc.question.exam.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ccxc.question.exam.dto.AreaDTO2;
import com.ccxc.question.exam.dto.DailyDTO;
import com.ccxc.question.exam.dto.ErrorDTO;
import com.ccxc.question.exam.dto.RankingDTO;
import com.ccxc.question.exam.dto.SummaryDTO;
import com.ccxc.question.exam.service.InformationService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/v1/open/information/manager")
@Api("用户信息相关API")
@Slf4j
public class InformationController {

    @Autowired
    private InformationService informationService;

    /**
     * @DEscription 功能说明  查看用户每日答题信息
     * 参数说明：
     */
    @GetMapping(value = "/day/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看用户每日答题信息", notes = "查看用户每日答题信息<br><br><b>@author 郑尚锟</b>")
    public List<DailyDTO> get(@ApiParam(value = "用户ID", required = true) @RequestParam(required = true, value = "id") String id) {
        log.debug("获取用户ID：{}", id);
        return informationService.findByuserId(id);
    }

    /**
     * @DEscription 功能说明  查看用户答题汇总
     * 参数说明：
     */
    @GetMapping(value = "/summary/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看用户答题汇总", notes = "查看用户答题汇总<br><br><b>@author 郑尚锟</b>")
    public SummaryDTO get1(@ApiParam(value = "用户ID", required = true) @RequestParam(required = true, value = "id") String id) {
        log.debug("获取用户ID：{}", id);
        return informationService.findByuserId2(id);
    }

    /**
     * @DEscription 功能说明  查看答题排名前50名的用户
     * 参数说明：
     */
    @GetMapping(value = "/ranking", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看答题排名前50名的用户", notes = "查看答题排名前50名的用户<br><br><b>@author 郑尚锟</b>")
    public List<RankingDTO> get2() {
        return informationService.ranking();
    }

    /**
     * @DEscription 功能说明 查看自己擅长领域
     * 参数说明：
     */
    @GetMapping(value = "/area/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看自己擅长领域", notes = "自己擅长领域<br><br><b>@author 郑尚锟</b>")
    public List<AreaDTO2> get3(@ApiParam(value = "用户ID", required = true) @RequestParam(required = true, value = "id") String id) {
        log.debug("获取用户ID：{}", id);
        return informationService.area(id);
    }

    /**
     * @DEscription 功能说明 查看错题
     * 参数说明：
     */
    @GetMapping(value = "/error/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看错题", notes = "查看错题<br><br><b>@author 郑尚锟</b>")
    public List<ErrorDTO> get4(@ApiParam(value = "用户ID", required = true) @RequestParam(required = true, value = "id") String id) {
        log.debug("获取用户ID：{}", id);
        return informationService.error(id);
    }

    /**
     * @DEscription 功能说明 查看用户自己的排名
     * 参数说明：
     */
    @GetMapping(value = "/Userranking/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(httpMethod = "GET", value = "查看用户自己的排名", notes = "查看用户自己的排名<br><br><b>@author 郑尚锟</b>")
    public int get5(@ApiParam(value = "用户ID", required = true) @RequestParam(required = true, value = "id") String id) {
        log.debug("获取用户ID：{}", id);
        return informationService.Userranking(id);
    }
}
